from digits import digits

units = { 1 : "one", 2: "two", 3: "three", 4: "four", 5: "five",
          6 : "six", 7: "seven", 8: "eight", 9: "nine" }

special = { 0 : "ten", 1 : "eleven", 2: "twelve", 3: "thirteen",
            4 : "fourteen", 5 : "fifteen", 6: "sixteen", 7: "seventeen",
            8 : "eighteen", 9 : "nineteen" }

tens = { 1: "ten", 2: "twenty", 3: "thirty", 4: "forty", 5: "fifty",
         6: "sixty", 7: "seventy", 8: "eighty", 9: "ninety" }

def write (h, t, u):
    if h == 0 and t == 0 and u == 0:
        return "onethousand"
    
    result = ""
    if h > 0:
        result += units[h]
        if t == 0 and u == 0:
            result += "hundred"
        else:
            result += "hundredand"
        
    if t == 1:
        result += special[u]
    else:
        if t > 1:
            result += tens[t]
        
        if u > 0:
            result += units[u]
            
    return result

print sum(len(write(h,t,u))
          for h in xrange(0, 10)
          for t in xrange(0, 10)
          for u in xrange(0, 10))
